"""
子类创建线程
"""
import threading


class SubThread(threading.Thread):
    """
    继承Thread类
    """
    def run(self):
        """
        重写run()方法
        """
        for i in range(3):
            print(f'线程{threading.current_thread().name}正在执行：', i)


if __name__ == '__main__':
    print(f'主线程{threading.current_thread().name}开始执行')

    # 创建子线程
    items = [SubThread() for _ in range(3)]

    # 启动子线程
    for item in items:
        item.start()
        item.join()

    print(f'主线程{threading.current_thread().name}执行结束')
